package LeetCode;

import java.util.LinkedHashMap;
import java.util.Map;

public class LC_146_LRUCache {

    public static void main(String[] args) {

    }

    public class LRUCache extends LinkedHashMap<Integer, Integer> {
        private int maxcapacity;

        public LRUCache(int capacity) {
            super(capacity, 0.75f, true);
            this.maxcapacity = capacity;
        }

        public int get(int key) {
            Integer vaule = super.get(key);
            if (vaule == null) return -1;
            else return vaule;
        }

        public void set(int key, int value) {
            super.put(key, value);
        }

        protected boolean removeEldestEntry(Map.Entry<Integer, Integer> eldest) {
            return size() > maxcapacity;
        }
    }

}